package com.cryann.mqttserver.mqttProcess.mqttMsgHandler;

import com.cryann.mqttserver.exception.MqttException;
import com.google.common.collect.ImmutableSet;
import io.netty.handler.codec.mqtt.MqttMessage;
import io.netty.handler.codec.mqtt.MqttMessageType;
import org.springframework.stereotype.Component;

import java.util.Set;

/**
 * @author cRyann
 * @date 2018/12/29 0029 09:02
 * @description: [MQTT-2.3.1-7]	与 [MQTT-2.3.1-6] 类似，SUBACK和UNSUBACK必须包含在对应的SUBSCRIBE和UNSUBSCRIBE报文中使用的报文标识符。
 */
@Component
public class MQTT_2$3$2_7 extends AbstractMqttHandler {
    @Override
    protected Set<MqttMessageType> handlerType() {
        return ImmutableSet.of(
                MqttMessageType.SUBACK,
                MqttMessageType.UNSUBACK);
    }

    @Override
    protected boolean checkMsg(MqttMessage message) {
        if ( false ) {
            throw new MqttException(" [MQTT-2.3.1-7] SUBACK和UNSUBACK必须包含在对应的SUBSCRIBE和UNSUBSCRIBE报文中使用的报文标识符。");
        }
        return true;
    }
}
